*******************************************************************************
* Load data
*******************************************************************************

use dataset_salience, clear

*******************************************************************************
* Y-axes
*******************************************************************************

foreach i in 10 100 1000 {
	local li = log(`i' + 1)
	local I = string(`i', "%20.0fc")
	local ly `li' "`I'"
	local ylab1 `ylab1' `ly'
}
foreach i in 10 100 1000 10000 100000 1000000 10000000 {
	local li = log(`i' + 1)
	local I = string(`i', "%20.0fc")
	if `i' == 10000 local I "10k"
	if `i' == 100000 local I "100k"
	if `i' == 1000000 local I "1m"
	if `i' == 10000000 local I "10m"
	local ly `li' "`I'"
	local ylab2 `ylab2' `ly'
}

*******************************************************************************
* Key events
*******************************************************************************

local michaelbrown = date("2014-08-01", "YMD")
local michaelbrownlabel = `michaelbrown' + 450
local georgefloyd = date("2020-05-01", "YMD")
local georgefloydlabel = `georgefloyd' + 350

*******************************************************************************
* Format date axis
*******************************************************************************

forvalues x = 2013(1)2022 {
	local mydate = date("`x'-01-01", "YMD")
	local mydates `mydates' `mydate' "`x'"
}

*******************************************************************************
* Articles
*******************************************************************************

#delimit; 

gr tw 
	(sc ln_count date, col(black) lwid(thick) msize(small)) 
	,
		xline(`michaelbrown' `georgefloyd', lpat(dash))
		plotregion(style(none))
		legend(off)
		xlab(`mydates')
		ylab(`ylab1', angle(horiz))
		xtitle("")
		ytitle("")
		title("{it:New York Times} articles")
		name(g1, replace)
		text(6.9 `michaelbrownlabel' "{&larr}Ferguson protests")
		text(6.9 `georgefloydlabel' "{&larr}George Floyd")
		ysize(2) 
		xsize(4)	
		scale(1.25)
		;

#delimit cr

*******************************************************************************
* Save articles
*******************************************************************************

gr export "figure_salience_a.pdf", replace

*******************************************************************************
* Tweets
*******************************************************************************

#delimit; 

gr tw 
	(sc ln_blm date, col(black) lwid(thick) msize(small)) 
	,
		xline(`michaelbrown' `georgefloyd', lpat(dash))
		plotregion(style(none))
		legend(off)
		xlab(`mydates')
		ylab(`ylab2', angle(horiz))
		xtitle("")
		ytitle("")
		title("Tweets")
		name(g2, replace)
		ysize(2) 
		xsize(4)		
		scale(1.25)
		;

#delimit cr

*******************************************************************************
* Save tweets
*******************************************************************************

gr export "figure_salience_b.pdf", replace

*******************************************************************************
* Google Trends
*******************************************************************************

#delimit; 

gr tw 
	(sc ln_hits date, col(black) lwid(thick) msize(small)) 
	,
		xline(`michaelbrown' `georgefloyd', lpat(dash))
		plotregion(style(none))
		legend(off)
		xlab(`mydates')
		ylab(`ylab1', angle(horiz))
		xtitle("")
		ytitle("")
		title("Google Searches")
		name(g2, replace)
		ysize(2) 
		xsize(4)		
		scale(1.25)	
		;

#delimit cr

*******************************************************************************
* Save Google Trends
*******************************************************************************

gr export "figure_salience_c.pdf", replace

*******************************************************************************
* End
*******************************************************************************
